<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>主页面</title>
</head>
<body>
    <script>
        httpRequestStartProcess = new XMLHttpRequest();
        function startProcess(e) {
            var processName = e.getAttribute("name");
            var url = "http://localhost:8080/exe-process?processName=";
            url = url.concat(processName);
            //httpRequestStartProcess = new XMLHttpRequest();
            httpRequestStartProcess.open("GET", url, true);
            httpRequestStartProcess.onreadystatechange = Response;
            httpRequestStartProcess.send();
            alert("正在运行: ".concat(processName))
        }
        function lookProcesses() {
            httpRequest = new XMLHttpRequest();
            httpRequest.open("GET", "http://localhost:8080/look-process");
            httpRequest.onreadystatechange = Response1;
            httpRequest.send();
        }
        function lookSystem() {
            httpRequest = new XMLHttpRequest();
            httpRequest.open("GET", "http://localhost:8080/look-system");
            httpRequest.onreadystatechange = Response2;
            httpRequest.send();
        }
        function Response() {
            if (httpRequestStartProcess.readyState == 4) {
                if (httpRequestStartProcess.status == 200) {
                    alert(httpRequestStartProcess.responseText)
                }
            }
        }
        function Response1() {
            if (httpRequest.readyState == 4) {
                if (httpRequest.status == 200) {
                    var div = document.getElementById("result1");
                    div.innerText = httpRequest.responseText;
                }
            }
        }
        function Response2() {
            if (httpRequest.readyState == 4) {
                if (httpRequest.status == 200) {
                    var div = document.getElementById("result2");
                    div.innerText = httpRequest.responseText;
                }
            }
        }
    </script>
    <!--请求测试-->
    <h3>process-common-1(普通进程)<button name="1" onclick="startProcess(this)">启动</button></h3>
    <h3>process-common-2(普通进程)<button name="2" onclick="startProcess(this)">启动</button></h3>
    <h3>process-common-3(普通进程)<button name="3" onclick="startProcess(this)">启动</button></h3>
    <h3>process-circulation-4(循环运行进程)<button name="4" onclick="startProcess(this)">启动</button></h3>
    <h3>process-circulation-5(循环运行进程)<button name="5" onclick="startProcess(this)">启动</button></h3>
    <h3>process-circulation-6(循环运行进程)<button name="6" onclick="startProcess(this)">启动</button></h3>
    <h3>process-illegalAccess-7(非法访问进程)<button name="7" onclick="startProcess(this)">启动</button></h3>
    <h3><button onclick="lookProcesses()">查看当前运行程序</button></h3>
    <div id="result1"></div>
    <h3><button onclick="lookSystem()">查看当前系统信息</button></h3>
    <div id="result2"></div>

</body>
</html>